// console.log('promise')

url1 = 'http://wx4.sinaimg.cn/large/44f2ef1bgy1gfn6zsqoi4j20u00humz8.jpg'
url2 = 'http://wx1.sinaimg.cn/large/44f2ef1bgy1gfnkprdpmyj20u01400wx.jpg'
function loading (src) {
    return new Promise(
        (resovle, reject) => {
            const img = document.createElement('img')
            img.onload = () => {
                resovle(img)
            }
            img.onerror = () => {
                reject(new Error('图片加载失败'))
            }
            img.src = src

        }
    )

}
loading(url1).then(img1 => {
    console.log(img1.width)
    return img1 // 返回普通对象
}).then(img1 => {
    console.log(img1.height)
    return loading(url2) //返回 promise 实例
}).then(img2 => {
    console.log(img2.width)
}).catch(ex => console.error(ex))
